package com.situ.address.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.situ.address.service.IAddressService;
import com.situ.address.vo.LayuiTableVO;

@Controller
@RequestMapping(value = "/address")
public class AddressController {

	@Autowired
	private IAddressService addressService;

	@GetMapping(value = "/index")
	public String index() {
		return "address";
	}

	@ResponseBody
	@GetMapping(value = "/tree")
	public LayuiTableVO tree() {
		return addressService.tree2();
	}

	@ResponseBody
	@PostMapping(value = "/save")
	public void save(String name, Integer parentId) {
		addressService.saveAddress(name, parentId);
	}
}
